package com.medical.HttpTools;
/** 
* @author  LTT-AH-ZY
* @date 创建时间：2017年9月14日 上午10:06:48 
* @version 1.0 
* @parameter 参数及其意义
* @since 最早使用该方法/类/接口的JDK版本 
* @since  
* @return  
*/

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;

public class DataAnalyze {
	/**
	 * @作用 对http返回的json数据进行解析，返回的是map格式的数据
	 * @param jsonarray
	 * @return
	 */
	public static List<Map<String, String>> JsonToList(JSONArray jsonarray){
		List<Map<String, String>> list = new ArrayList<>();
		for(int i=0;i<jsonarray.length();i++){
			Map<String,String> map = new HashMap<>();
        	JSONObject job = jsonarray.getJSONObject(i);
        	map.put("id", job.get("hospdeptid").toString());
        	map.put("name", job.get("hospdeptname").toString());
        	list.add(map);
        	System.out.println("----数据："+job) ;
        }
		return list;
	}
	/**
	 * 会诊医生解析类，对传输接收的json信息进行解析
	 * @param jsonarray
	 * @return
	 */
	public static List<Map<String, String>> DoctorJsonToList(JSONArray jsonarray){
		List<Map<String, String>> list = new ArrayList<>();
		for(int i=0;i<jsonarray.length();i++){
			Map<String,String> map = new HashMap<>();
        	JSONObject job = jsonarray.getJSONObject(i);
        	map.put("docloginid", job.get("docloginid").toString());//医生表登陆id
        	map.put("docloginpix", job.get("docloginpix").toString());//头像
        	map.put("docloginname", job.get("docloginname").toString());//登陆名
        	map.put("docallday", job.get("docallday").toString());//是否全天接诊
        	map.put("docloginphone", job.get("docloginphone").toString());//登陆手机
        	map.put("dochosp", job.get("dochosp").toString());//所属医院
        	map.put("docdept", job.get("docdept").toString());//所属科室
        	map.put("docage", job.get("docage").toString());//年龄
        	map.put("docmale", job.get("docmale").toString());//性别
        	
        	map.put("doctitlename", job.get("doctitle").toString());//医生职称
        	map.put("docname", job.get("docname").toString());//真实姓名
        	map.put("docbirthday", job.get("docbirthdate").toString());//出生日期
        	map.put("docloc", job.get("dochospprovince").toString()+job.get("dochospcity").toString()+job.get("dochosparea").toString()+job.get("dochospother").toString());//医生所在地
        	map.put("docnation", job.get("docnation").toString());//民族
        	map.put("docexpert", job.get("docexpert").toString());//擅长疾病
        	map.put("docabs", job.get("docabs").toString());//医生简介
        	
        	list.add(map);
        	//System.out.println("----数据："+job) ;
        }
		return list;
	}
	/**
	 * 订单解析类，对传输的json信息进行解析，再重新封装 JSONArray ===> List<Map<String,Object>>
	 * @param jsonarray
	 * @return
	 */
	public static List<Map<String, Object>> UserOrderJsonToList(JSONArray jsonarray){
		List<Map<String, Object>> list = new ArrayList<>();
		for(int i=0;i<jsonarray.length();i++){
			Map<String,Object> map = new HashMap<>();
        	JSONObject job = jsonarray.getJSONObject(i);
        	map.put("userorderid", job.get("userorderid").toString());//订单id
        	map.put("userorderchosehosptime", job.get("userorderchosehosptime").toString());//预约医院时间
        	map.put("userorderdocloginid", job.get("userorderdocloginid").toString());//预约医生登陆ID
        	map.put("docname", job.get("docname").toString());//预约医生姓名
        	map.put("userorderdeposit", job.get("userorderdeposit").toString());//住院押金
        	map.put("userordertotaldeposit", job.get("userordertotaldeposit").toString());
        	map.put("userorderleavehosptime", job.get("userorderleavehosptime").toString());
        	map.put("userorderhprice", job.get("userorderhprice").toString());//最终成交价格
        	map.put("userorderstateid", job.get("userorderstateid").toString());//订单状态码
        	map.put("userorderstatename", job.get("userorderstatename").toString());//订单状态字
        	map.put("familyname", job.get("familyname").toString());//
        	map.put("usersickpic", job.get("usersickpic").toString());//
        	map.put("userorderhospseconddept", job.get("userorderhospseconddept").toString());//
        	map.put("familyage", job.get("familyage").toString());//看病
        	map.put("userorderhospconfirmtime", job.get("userorderhospconfirmtime").toString());//
        	map.put("userorderhospprimarydept", job.get("userorderhospprimarydept").toString());//
        	map.put("familymale", job.get("familymale").toString());//
        	map.put("userorderactualhospitalizationid", job.get("userorderactualhospitalizationid").toString());//
        	map.put("actualhospitalizationstatename", job.get("actualhospitalizationstatename").toString());//
        	list.add(map);
        	//System.out.println("----数据："+job) ;
		}
		return list;
	}
	/**
	 * 我的消息解析类，对传输的json数据进行解析，再重新封装，JSONArray ===》 List<Map<String,Object>>
	 * @param jsonarray
	 * @return
	 */
	public static List<Map<String,Object>> MessageJsonToList(JSONArray jsonarray){
		List<Map<String, Object>> list = new ArrayList<>();
		for(int i=0;i<jsonarray.length();i++){
			Map<String,Object> map = new HashMap<>();
        	JSONObject job = jsonarray.getJSONObject(i);
        	map.put("notificationid", job.get("notificationid").toString());//通知id
        	map.put("notificationtitle", job.get("notificationtitle").toString());//通知标题
        	map.put("notificationwords", job.get("notificationwords").toString());//通知内容
        	map.put("notificationtypeid", job.get("notificationtypeid").toString());//通知类型id
        	map.put("notificationtypename", job.get("notificationtypename").toString());//通知类型名称
        	map.put("notificationcreatetime", job.get("notificationcreatetime").toString());//通知创建时间
        	map.put("notificationread", job.get("notificationread").toString());//通知是否已读
        	map.put("notificationreadtime", job.get("notificationreadtime").toString());//通知读取时间
        	map.put("notificationdata", job.get("notificationdata").toString());//通知json信息（包含某个订单信息或会诊信息）
        	list.add(map);
        	//System.out.println("----数据："+job) ;
		}
		return list;
	}
	
	public static List<Map<String,Object>> MyOrderJsonToList(JSONArray jsonarray){
		List<Map<String, Object>> list = new ArrayList<>();
		for(int i=0;i<jsonarray.length();i++){
			Map<String,Object> map = new HashMap<>();
        	JSONObject job = jsonarray.getJSONObject(i);
        	map.put("hosporderid", job.get("hosporderid").toString());//会诊id
        	map.put("dochosp", job.get("dochosp").toString());//通知标题
        	map.put("orderptime", job.get("orderptime").toString());//通知内容
        	map.put("orderstate", job.get("orderstate").toString());//通知类型id
        	map.put("hosporderstatename", job.get("hosporderstatename").toString());//通知类型名称
        	map.put("doctitle", job.get("doctitle").toString());//通知创建时间
        	map.put("orderetime", job.get("orderetime").toString());//通知是否已读
        	map.put("orderrtime", job.get("orderrtime").toString());//通知读取时间
        	map.put("ordertotalhospprice", job.get("ordertotalhospprice").toString());
        	map.put("ordertotaldoctorprice", job.get("ordertotaldoctorprice").toString());
        	map.put("hospid", job.get("hospid").toString());
        	map.put("doctorid", job.get("doctorid").toString());
        	map.put("orderabs", job.get("orderabs").toString());
        	map.put("docmale", job.get("docmale").toString());
        	map.put("docname", job.get("docname").toString());
        	map.put("orderstime", job.get("orderstime").toString());
        	list.add(map);
        	//System.out.println("----数据："+job) ;
		}
		return list;
	}
	/**
	 * 日程解析类，解析传输的每个医生的日程表
	 * @param jsonarray
	 * @return
	 */
	public static List<Map<String, Object>> CalendarJsonToList(JSONArray jsonarray){
		List<Map<String, Object>> list = new ArrayList<>();
		for(int i=0;i<jsonarray.length();i++){
			Map<String,Object> map = new HashMap<>();
        	JSONObject job = jsonarray.getJSONObject(i);
        	map.put("doccalendarid", job.get("doccalendarid").toString());
        	map.put("doccalendaradressid", job.get("doccalendaradressid").toString());
        	map.put("docaddresslocation", job.get("docaddresslocation").toString());
        	map.put("docaddresscity", job.get("docaddresscity").toString());
        	map.put("docaddresslat", job.get("docaddresslat").toString());
        	map.put("doccalendartime", job.get("doccalendartime").toString());
        	map.put("doccalendarday", job.get("doccalendarday").toString());
        	map.put("docaddressother", job.get("docaddressother").toString());
        	map.put("docaddressprovince", job.get("docaddressprovince").toString());
        	map.put("docaddressarea", job.get("docaddressarea").toString());
        	map.put("docaddresslon", job.get("docaddresslon").toString());
        	map.put("doccalendaraffair", job.get("doccalendaraffair").toString());
        	list.add(map);
        	//System.out.println("----数据："+job) ;
        }
		return list;
	}
	/**
	 * 项目单价json转换成list
	 * @param jsonarray
	 * @return
	 */
	public static List<Map<String,Object>> UnitpriceJsonToList(JSONArray jsonarray){
		List<Map<String, Object>> list = new ArrayList<>();
		for(int i=0;i<jsonarray.length();i++){
			Map<String,Object> map = new HashMap<>();
        	JSONObject job = jsonarray.getJSONObject(i);
        	map.put("unitpriceid", job.get("unitpriceid").toString());
			map.put("unitpricename", job.get("unitpricename").toString());
			map.put("unitpricenumber", job.get("unitpricenumber").toString());
			map.put("unitpriceabs", job.get("unitpriceabs").toString());
			map.put("unitpriceoperatetime", job.get("unitpriceoperatetime").toString());
        	list.add(map);
        	//System.out.println("----数据："+job) ;
        }
		return list;
	}
	/**
	 * 套餐单价json转换成list
	 * @param jsonarray
	 * @return
	 */
	public static List<Map<String,Object>> PackageJsonToList(JSONArray jsonarray){
		List<Map<String, Object>> list = new ArrayList<>();
		for(int i=0;i<jsonarray.length();i++){
			Map<String,Object> map = new HashMap<>();
        	JSONObject job = jsonarray.getJSONObject(i);
        	map.put("packageid", job.get("packageid").toString());
			map.put("packagename", job.get("packagename").toString());
			map.put("packagenumber", job.get("packagenumber").toString());
			map.put("packageabs", job.get("packageabs").toString());
			map.put("packageoperatetime", job.get("packageoperatetime").toString());
			map.put("packagesustime", job.get("packagesustime").toString());
        	list.add(map);
        	//System.out.println("----数据："+job) ;
        }
		return list;
	}
	/**
	 * 获取交易记录的json转换成list
	 * @param jsonarray
	 * @return
	 */
	public static List<Map<String,Object>> TraderecordJsonToList(JSONArray jsonarray){
		List<Map<String,Object>> list = new ArrayList<>();
		for(int i=0;i<jsonarray.length();i++) {
			Map<String,Object> map = new HashMap<>();
			JSONObject job = jsonarray.getJSONObject(i);
			map.put("payid", job.get("payid").toString());
			map.put("paytradeno", job.get("paytradeno").toString());
			map.put("payorderid", job.get("payorderid").toString());
			map.put("paywxtradeno", job.get("paywxtradeno").toString());
			map.put("payalipaytradeno", job.get("payalipaytradeno").toString());
			map.put("paycreattime", job.get("paycreattime").toString());
			map.put("paystateid", job.get("paystateid").toString());
			map.put("paystatename", job.get("paystatename").toString());
			map.put("paymodeid", job.get("paymodeid").toString());
			map.put("paymodename", job.get("paymodename").toString());
			map.put("paytotalamount", job.get("paytotalamount").toString());
			map.put("payreceiptamount", job.get("payreceiptamount").toString());
			map.put("paytypeid", job.get("paytypeid").toString());
			map.put("paytypename", job.get("paytypename").toString());
			map.put("payremark", job.get("payremark").toString());
			map.put("payendtime", job.get("payendtime").toString());
			list.add(map);
		}
		return list;
	}
	/**
	 * 获取余额变动记录json转换成List
	 * @param jsonarray
	 * @return
	 */
	public static List<Map<String,Object>> BalancerecordJsonToList(JSONArray jsonarray){
		List<Map<String,Object>> list = new ArrayList<>();
		for(int i=0;i<jsonarray.length();i++) {
			Map<String,Object> map = new HashMap<>();
			JSONObject job = jsonarray.getJSONObject(i);
			map.put("hosppurseid", job.get("hosppurseid").toString());
			map.put("hosppursetypeid", job.get("hosppursetypeid").toString());
			map.put("pursetypename", job.get("pursetypename").toString());
			map.put("hosppursetime", job.get("hosppursetime").toString());
			map.put("hosppurseamount", job.get("hosppurseamount").toString());
			map.put("payid", job.get("payid").toString());
			map.put("hosppursebalance", job.get("hosppursebalance").toString());
			list.add(map);
		}
		return list;
	}
}
